package com.company.card_service.serviceImpl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.company.card_service.model.PassageView;
import com.company.card_service.mapper.PassageViewMapper;
import com.company.card_service.service.PassageViewService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;

import java.util.Date;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author 赵志浩
 * @since 2022-09-15 04:15:07
 */
@Service
public class PassageViewServiceImpl extends ServiceImpl<PassageViewMapper, PassageView> implements PassageViewService {

    @Override
    public Boolean savePassageView(PassageView passageView) {
        LambdaQueryWrapper<PassageView> wrapper = new LambdaQueryWrapper<>();
        wrapper.eq(PassageView::getUserId,passageView.getUserId());
        wrapper.eq(PassageView::getPassageId,passageView.getPassageId());
        PassageView passageView1 = baseMapper.selectOne(wrapper);
        if(passageView1 == null){
            passageView.setCreateTime(new Date());
            baseMapper.insert(passageView);
        }
        return true;
    }
}
